home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieE-Pipoca.py < prev    next >
Text File  |  2008-11-17  |  5KB  |  153 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieE-Pipoca.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2005-2007 Vasco Nunes, Piotr O┼╝arowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. # Updated on 04/29/2007 by Djohnson "Joe" Lima
  25. # joe1310@terra.com.br - S├úo Paulo/Brasil
  26.  
  27. import gutils, movie, string
  28.  
  29. plugin_name = "E-Pipoca"
  30. plugin_description = "E-Pipoca Brasil"
  31. plugin_url = "epipoca.uol.com.br"
  32. plugin_language = _("Brazilian Portuguese")
  33. plugin_author = "Vasco Nunes"
  34. plugin_author_email="<vasco.m.nunes@gmail.com>"
  35. plugin_version = "0.5"
  36.  
  37. class Plugin(movie.Movie):
  38.     "A movie plugin object"
  39.     def __init__(self, id):
  40.         self.encode='iso-8859-1'
  41.         self.movie_id = id
  42.         self.url = "http://epipoca.uol.com.br/filmes_detalhes.php?idf=" + str(self.movie_id)
  43.  
  44.     def get_image(self):
  45.         "Find the film's poster image"
  46.         tmp_pic = gutils.trim(self.page, "images/filmes/poster/poster_", "\"")
  47.         self.image_url = \
  48.             "http://epipoca.uol.com.br/images/filmes/poster/poster_" + tmp_pic
  49.  
  50.     def get_o_title(self):
  51.         "Find the film's original title"
  52.         self.o_title = string.capwords(gutils.trim(self.page, "</font><br>(", ", "))
  53.  
  54.     def get_title(self):
  55.         """Find the film's local title.
  56.         Probably the original title translation"""
  57.         self.title = gutils.trim(self.page, "<TITLE>", " (")
  58.  
  59.     def get_director(self):
  60.         "Find the film's director"
  61.         self.director = gutils.trim(self.page, "<b>Diretor(es): </b>", "</a></td>")
  62.  
  63.     def get_plot(self):
  64.         "Find the film's plot"
  65.         self.plot = gutils.trim(self.page, "<b>SINOPSE</b></font><br><br>", "</td></tr>")
  66.  
  67.     def get_year(self):
  68.         "Find the film's year"
  69.         self.year = gutils.trim(self.page, "<a href=\"busca_mais.php?opc=ano&busca=", "\">")
  70.  
  71.     def get_runtime(self):
  72.         "Find the film's running time"
  73.         self.runtime = gutils.trim(self.page, "<td><b>Dura", " min.</td>")
  74.         self.runtime = self.runtime[9:]
  75.  
  76.     def get_genre(self):
  77.         "Find the film's genre"
  78.         self.genre = gutils.trim(self.page, "<a href=\"busca_mais.php?opc=genero&busca=", "\">")
  79.  
  80.     def get_cast(self):
  81.         "Find the actors. Try to make it line separated."
  82.         self.cast = ""
  83.         self.cast = gutils.trim(self.page, "<b>Elenco: </b>", "<b>mais...</b>")
  84.         self.cast = gutils.strip_tags(self.cast)
  85.         self.cast = self.cast[:-2]
  86.  
  87.     def get_classification(self):
  88.         "Find the film's classification"
  89.         self.classification = ""
  90.  
  91.     def get_studio(self):
  92.         "Find the studio"
  93.         self.studio = gutils.trim(self.page, "<b>Distribuidora(s): </b>", "</a></td>")
  94.  
  95.     def get_o_site(self):
  96.         "Find the film's oficial site"
  97.         self.o_site = "http://epipoca.uol.com.br/filmes_web.php?idf=" + str(self.movie_id)
  98.  
  99.     def get_site(self):
  100.         "Find the film's imdb details page"
  101.         self.site = "http://epipoca.uol.com.br/filmes_ficha.php?idf=" + str(self.movie_id)
  102.  
  103.     def get_trailer(self):
  104.         "Find the film's trailer page or location"
  105.         self.trailer = "http://epipoca.uol.com.br/filmes_trailer.php?idf=" + str(self.movie_id)
  106.             
  107.     def get_country(self):
  108.         "Find the film's country"
  109.         self.country = gutils.trim(self.page, "<a href=\"busca_mais.php?opc=pais&busca=", "\">")
  110.  
  111.     def get_rating(self):
  112.         """Find the film's rating. From 0 to 10.
  113.         Convert if needed when assigning."""
  114.         tmp_rating = gutils.trim(self.page, "<br><b>Cota", " (")
  115.         tmp_rating = gutils.after(tmp_rating, "</b>")
  116.         if tmp_rating <> "":
  117.             tmp_rating = string.replace(tmp_rating,',','.')
  118.             self.rating = str( float(string.strip(tmp_rating)) )
  119.         else:
  120.             self.rating = ""
  121.  
  122. class SearchPlugin(movie.SearchMovie):
  123.     "A movie search object"
  124.     def __init__(self):
  125.         self.original_url_search = \
  126.             "http://epipoca.uol.com.br/busca.php?opc=todos&busca="
  127.         self.translated_url_search = \
  128.             "http://epipoca.uol.com.br/busca.php?opc=todos&busca="
  129.         self.encode='iso-8859-1'
  130.  
  131.     def search(self, parent_window):
  132.         "Perform the web search"
  133.         self.open_search(parent_window)
  134.         self.sub_search()
  135.         return self.page
  136.  
  137.     def sub_search(self):
  138.         "Isolating just a portion (with the data we want) of the results"
  139.         self.page = gutils.trim(self.page, \
  140.             " Resul","><b>Not") 
  141.  
  142.     def get_searches(self):
  143.         "Try to find both id and film title for each search result"
  144.         elements = string.split(self.page, "<td width=\"55\" align=\"center\" bgcolor=")
  145.         self.number_results = elements[-1]
  146.  
  147.         if (elements[0] != ''):
  148.             for element in elements:
  149.                 self.ids.append(gutils.trim(element, "<a href=\"filmes_detalhes.php?idf=", "\">"))
  150.                 self.titles.append(gutils.strip_tags(gutils.trim(element, "<font class=\"titulo\">", "<b>Adicionar aos meus filmes favoritos</b>") ))
  151.         else:
  152.             self.number_results = 0
  153.